package com.sky.Push;

import com.sky.Entity.PushManage;
import com.sky.Protocol.MessageProtocol;
import com.sky.Util.DESEncryptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by sun on 2017-06-13.
 */
public class PushTread implements Runnable {

    private Logger logger = LoggerFactory.getLogger(PushTread.class);

    private int msgType;
    private String content;

    public PushTread(PushManage pushManage) {
        this.msgType = pushManage.getMsgType();
        this.content = pushManage.getContent();
    }

    public PushTread(String content)
    {
        this.msgType = 1;
        this.content = content;
    }

    public void run()
    {
        logger.info("push thread content {}",content);

        //body加密
        String contenEnc = DESEncryptor.getEnc(content);

        MessageProtocol msg = new MessageProtocol(1,msgType,0,0,contenEnc);
        ClientManager clientManager = ClientManager.getInstance();
        clientManager.pushAllClient(msg);

        logger.info("push server thread run finish!");
    }
}
